#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018/1/17 0017 9:23
# @Author  : Arliki
# @email   : hkdnxycz@outlook.com
# @File    : distribut_4
import queue
from multiprocessing.managers import BaseManager
import time


class R(BaseManager):
    pass


class Worker:
    def __init__(self):
        self.send = queue.Queue()
        self.receive = queue.Queue()

    def beg(self):
        R.register('get_send')
        R.register('get_receive')
        ip = "127.0.0.1"
        port = 5000
        print("connect to:", ip, "on port:", port)
        worker = R(address=(ip, port), authkey=b'abcd')
        worker.connect()

        send = worker.get_send()
        receive = worker.get_receive()
        while True:
            id = send.get(timeout=2)
            print("is get", id)
            time.sleep(1)
            receive.put(id)


if __name__ == '__main__':
    work = Worker()
    work.beg()
